package com.garlic.face.jlf.model;

import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class BaseBean {
    private String code;

    private String msg;

    private String data;

    public String getCode() {
        if (TextUtils.isEmpty(this.code)) {
            return "";
        } else {
            return code;
        }
    }

    public String getMsg() {
        if (TextUtils.isEmpty(this.msg)) {
            return "";
        } else {
            return msg;
        }
    }

    public String getData() {
        return data;
    }

    public boolean isOk() {
        if (!TextUtils.isEmpty(this.code) && "0".equals(code)) {
            return true;
        } else {
            return false;
        }
    }

    public void parse(String in) {
        JSONObject root = JSON.parseObject(in);
        String code = root.getString("code");
        String msg = root.getString("msg");
        this.code = code;
        this.msg = msg;
        if (root.containsKey("data")) {
            this.data = root.getString("data");
        }
    }
}
